//多态
public class Test4 {
    public static void main(String[] args) {
        show(new Cat());
        Animal a = new Cat();//向上转型
        a.eat();
        Cat c = (Cat) a;//向下转型
        c.play();
    }
    public static void show(Animal a) {
        a.eat();
        if (a instanceof Cat) {
            Cat c = (Cat) a;
            c.play();
        }
    }
}
abstract class Animal {
    abstract void  eat();
}
class Cat extends  Animal {
    @Override
    void eat() {
        System.out.println("猫吃鱼");
    }
    void play() {
        System.out.println("猫玩老鼠");
    }
}